<?php
/**
 * Created by PhpStorm.
 * User: Mloong
 * Date: 2019/4/15
 * Time: 11:38
 */

namespace app\common\validate;


use app\lib\exception\ParameterException;
use think\facade\Validate;

class BaseValidate extends Validate
{
    public function goCheck()
    {
        # 对每个参数进行验证
        $param = Request::param();
        # 调用check() 方法对每个参数进行检查
        $result = $this->batch()->check($param);
        # 如果检验失败则抛出异常
        if ($result == false) {
            $str = implode('!', $this->getError());
            throw new ParameterException([
                'msg' => $this->getError(),
            ]);
        }
    }
}